﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Popup.Master" AutoEventWireup="true"
    CodeBehind="PaymentAmount.aspx.cs" Inherits="SapB1WebPOS.PaymentAmount" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PopupContent" runat="server">
    <script type="text/javascript">
        var paymentCode;
        var docTotal = 0;
        var totalPaymentAmount = 0;
        $(document).ready(function () {
            $('#remain').click(function () {
                $("#errMsg").text('');
                if ($(this).is(':checked')) {
                    $("#Amount").prop("disabled", true).addClass("k-state-disabled");
                    $("#Amount").val(parseFloat(docTotal) - parseFloat(totalPaymentAmount));
                } else {
                    $("#Amount").val("0");
                    $("#Amount").prop("disabled", false).removeClass("k-state-disabled");
                    setTimeout(function () { $("#Amount").focus(); $("#Amount").select() }, 1);
                }
            });
            paymentCode = '<%= Request.QueryString["PaymentCode"] %>';
            docTotal = '<%= Request.QueryString["GrandTotal"] %>';
            totalPaymentAmount = '<%= Request.QueryString["TotalPaymentAmount"] %>';

            setTimeout(function () { $("#Amount").focus(); $("#Amount").select() }, 1);
            $("#Amount").keydown(function (event) {
                $("#errMsg").text('');
                if (event.keyCode == 13) {
                    event.preventDefault();
                    var amount = $("#Amount").val();
                    amount = amount.trim();
                    if (amount == '') {
                        $("#errMsg").text('Please input Payment Amount');
                        return false;
                    }
                    else {
                        UpdatePaymentAmount(amount);
                    }
                }
            });
        });

        function UpdatePaymentAmount(amount) {
            parent.UpdatePayment(amount, paymentCode);
        }
        function btnAccept_onclick() {
            var amount = $("#Amount").val();
            amount = amount.trim();
            if (amount == '') {
                $("#errMsg").text('Please input Payment Amount');
            }
            else {
                UpdatePaymentAmount(amount);
            }
        }

        function btnCancel_onclick() {
            parent.$("#paymentAmount").data("kendoWindow").close();
        }

    </script>
    <table style="width: 100%; height: 100%;" border="0px">
        <tr>
            <td align="center">
                <input type="text" name="Amount" id="Amount" style="width: 480px; height: 60px; font-size: 24pt;
                    font-family: Courier New;" class="k-input k-textbox" value="0" />
            </td>
        </tr>
        <tr>
            <td>
                <br />
            </td>
        </tr>
        <tr>
            <td align="center">
                <input type="checkbox" id="remain" name="remain" class="k-checkbox" />
                <label class="k-checkbox-label" for="remain" style="font-family: Courier New; font-size: 22pt;">
                    Remain</label>
            </td>
        </tr>
        <td>
            <br />
        </td>
        <tr>
            <td align="center">
                <button type="button" id="btnAccept" class="k-button k-button-icontext k-primary"
                    style="width: 150px; height: 50px;" onclick="return btnAccept_onclick()">
                    <span class="k-icon k-update"></span>Accept</button>&nbsp;
                <button type="button" id="btnCancel" class="k-button k-button-icontext k-grid-cancel"
                    style="width: 150px; height: 50px;" onclick="return btnCancel_onclick()">
                    <span class="k-icon k-i-cancel"></span>Cancel</button>
            </td>
        </tr>
        <tr>
            <td>
                <br />
            </td>
        </tr>
        <tr>
            <td align="center">
                <span id="errMsg" class="fake" style="font-family: Tahoma;"></span>
            </td>
        </tr>
    </table>
</asp:Content>
